package com.kid.keep.mapper;

import com.kid.keep.dto.AddUserDTO;
import com.kid.keep.dto.UserDTO;
import com.kid.keep.po.User;
import com.kid.keep.request.AddUserRequest;
import com.kid.keep.vo.AddUserVO;
import com.kid.keep.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.Date;

/**
 * @Description 转换mapper
 * @Author JOHN
 * @Create 2020-01-02
 * @Since 1.0.0
 */
@Mapper(componentModel = "spring")
public interface IUserCovertMapper {
    /**
     * model to  dto
     *
     * @param user
     * @return
     */
    UserDTO toDTO(User user);
    /**
     * dto to  vo
     *
     * @param userDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    UserVO toVO(UserDTO userDTO);

    /**
     * dto to po
     *
     * @param userDTO
     * @param updateDate
     * @param openId
     * @return
     */
    @Mappings({
            @Mapping(target = "appId", source = "appId")
    })
    User toPO(AddUserDTO userDTO, Date updateDate,String openId,Long appId);

    /**
     * request to dto
     *
     * @param addUserRequest
     * @return
     */
    AddUserDTO toDTO(AddUserRequest addUserRequest);

    /**
     * dto to response
     *
     * @param userDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    AddUserVO toAddUserVO(UserDTO userDTO);

}
